package com.ruoyi.project.g6.entity.common;

import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * @author author
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class G6Record implements Serializable {

    private static final long serialVersionUID = 1576464757498L;


    /**
     * 主键
     * <p>
     * isNullAble:0
     */
    private Long id;

    /**
     * 型号
     * isNullAble:0
     */
    private String model;

    /**
     * 厂商名称
     * isNullAble:1
     */
    private String factoryName;
    /**
     * 参数类型
     * @see {G6RecordParameter}
     * isNullAble:0
     */
    private String type;
    /**
     * 请求数据体
     * isNullAble:1
     */
    private String data;


    /**
     * 返回的数据体
     * isNullAble:1
     */
    private String responseData;

    /**
     * isNullAble:1
     */
    private Date createTime;


    public static G6Record newInstance(G6RecordParameter g6RecordParameter, ResponseResult responseResult) {
        return new G6Record(
                null,
                g6RecordParameter.getModel(),
                g6RecordParameter.getFactoryName(),
                g6RecordParameter.getType(),
                JSON.toJSONString(g6RecordParameter),
                JSON.toJSONString(responseResult),
                new Date()
        );
    }
}
